package tieba.core;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.BeanUtils;

public class CommonUtils {

	public static <T> T Clone(Class<T> clazz, Object entity) {
		T obj = null;
		try {
			obj = (T) Class.forName(clazz.getName()).newInstance();
			BeanUtils.copyProperties(obj, entity);
		} catch (IllegalAccessException | InvocationTargetException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return obj;
	}
}
